'''
Created on 26.12.2011

@author: hkh
'''
from REIBOR import *
from datetime import date
from numpy import *
from scipy.interpolate import interp1d
from scipy import interpolate
from matplotlib import *
import matplotlib.pyplot as plt

curvepoints = []
ddate = date(2011,11,11)

curvepoints.append(REIBOR9M(ddate, 0.02))
curvepoints.append(REIBOR2M(ddate, 0.05))
curvepoints.append(REIBOR3M(ddate, 0.06))
curvepoints.append(REIBOR6M(ddate, 0.02))
curvepoints.append(REIBOR3M(ddate, 0.06))
curvepoints.append(REIBOR12M(ddate, 0.01))
curvepoints.append(REIBOR1M(ddate, 0.04))

curvepoints.sort(key=lambda point: point.maturitydate)
#b = sorted(self.curvepoints, key=lambda point: point.maturitydate)

for obj in curvepoints:
    print obj.maturitydate, obj.discountfactor(), obj.continuousrate(), obj.yearfrac()

t = array([obj.yearfrac() for obj in curvepoints])
y = array([obj.continuousrate() for obj in curvepoints])

f1 = interp1d(t, y)

x = linspace(0.2, 1, 1000)

a = f1(x)

plt.plot(x,a)
plt.show()